package com.example.clxy.controller;

import com.example.clxy.entity.Wlclass;
import com.example.clxy.interceptor.AppToken;
import com.example.clxy.result.PageResult;
import com.example.clxy.result.StandardResult;
import com.example.clxy.result.WebRestResult;
import com.example.clxy.result.business.GradeResult;
import com.example.clxy.result.business.PageResult.ClassPageResult;
import com.example.clxy.result.business.WlClassResult;
import com.example.clxy.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author weichong
 * date 2020-08-03
 * @Description:
 */

@RestController
@RequestMapping("ClassController")
@CrossOrigin
@AppToken
public class ClassController {

    @Autowired
    private ClassService classService;

    /**
     * 查询所有年级接口
     */
    @RequestMapping("getAllGrade")
    public StandardResult getAllGrade() {
        return classService.getAllGrade();
    }

    /**
     * 查询所有年级接口
     */
    @RequestMapping("getAllGradeClass")
    public StandardResult getAllGradeClass() {
        return classService.getAllGradeClass();
    }

    /**
     * 获取班级列表接口,只传page和pagesize查所有班级信息
     */
    @RequestMapping("getClassList")
    public PageResult<ClassPageResult> getClassList(String teacherid, String semesterid, String classname, String grade, int page, int pagesize) {
        PageResult<ClassPageResult> res = classService.getClassList(teacherid, semesterid, classname, grade, page, pagesize);
        return res;
    }



    @PostMapping("WlclassbindSpecialty")
    public WebRestResult WlclassbindSpecialty(String wlclassid, String specialtyid) {
        WebRestResult result = classService.WlclassbindSpecialty(wlclassid, specialtyid);
        return result;
    }

    @RequestMapping("getClassController")
    public StandardResult getClassController(String classid) {
        return classService.getClassController(classid);
    }

    @PostMapping("addWlclass")
    public WebRestResult addWlclass(@RequestBody Wlclass wlclass) {
        WebRestResult result = classService.addWlclass(wlclass);
        return result;
    }

    @PostMapping("updateWlclass")
    public WebRestResult updateWlclass(@RequestBody Wlclass wlclass) {
        WebRestResult result = classService.updateWlclass(wlclass);
        return result;
    }

    @PostMapping("deleteWlclass")
    public WebRestResult deleteWlclass(String wlclassid) {
        WebRestResult result = classService.deleteWlclass(wlclassid);
        return result;
    }

    @GetMapping("getWlclassList")
    public PageResult<ClassPageResult> getWlclassList(int page, int pagesize, String wlclassname, String grade) {
        PageResult<ClassPageResult> result = classService.getWlclassList(page, pagesize, wlclassname, grade);
        return result;
    }

    @GetMapping("getWlclassById")
    public WlClassResult getWlclassById(String wlclassid) {
        WlClassResult result = classService.getWlclassById(wlclassid);
        return result;
    }
}
